$(function () {

    //
    $("#recharge").click(function () {
        window.location.href = "recharge";
    })

    $("#invite").click(function () {
        window.location.href = "invite"
    });

    $("#win").click(function () {
        window.location.href = "win"
    });

    $("#reward").click(function () {
        window.location.href = "reward"
    });

    $("#mime").click(function () {
        window.location.href = "mime"
    });


    $("#mime_recharge").click(function () {
        window.location.href = "recharge"
    });

    $("#mime_with_drawal").click(function () {
        window.location.href = "withdrawal"
    });

    $("#promotion").click(function () {
        window.location.href = "withdrawal"
    })


    $("#about").click(function () {
        $("#about_next").toggle()
    })
    $("#wallet").click(function () {
        $("#wallet_next").toggle()
    })

    $("#wallet_recharge").click(function () {
        window.location.href = "recharge"
    })

    $("#wallet_withdrawal").click(function () {
        window.location.href = "withdrawal"
    })

    $("#wallet_transactions").click(function () {
        window.location.href = "income"
    })

    $("#privacypolicy").click(function () {
        window.location.href = "privacypolicy"
    })

    $("#risk_disclosure_agree").click(function () {
        window.location.href = "agreement"
    })

    $("#mime_reset_pwd").click(function () {
        window.location.href = "forget"
    })

    $("#bank_card_ol").click(function () {
        window.location.href = "bankCard"
    })
    $("#privilegeViewMore").click(function () {
        //VIP privilege
        $("#privilegesViewMoreDiv").css({"display": "block"})
    })
    $("#closeprivilegesViewMore").click(function () {
        //VIP privilege
        $("#privilegesViewMoreDiv").css({"display": "none"})
    })
    isExitTodaySignIn();
    $(".nav_order_bar_main").find("li").click(function () {
        var tagId = $(this).attr("id");
        if (tagId == 'withDrawalQuota') {
            $("#withDrawalServices").addClass("active_order_normal").removeClass("active_order_sel");
            $("#vipRewards").addClass("active_order_normal").removeClass("active_order_sel");
            $("#withDrawalQuota").addClass("active_order_sel").removeClass("active_order_normal")
            $("#withdrawalQuatoTable").show();
            $("#withDrawalServicesTable").hide();
            $("#vipRewardsTable").hide();

        } else if (tagId == 'withDrawalServices') {
            $("#withDrawalQuota").addClass("active_order_normal").removeClass("active_order_sel");
            $("#vipRewards").addClass("active_order_normal").removeClass("active_order_sel");
            $("#withDrawalServices").addClass("active_order_sel").removeClass("active_order_normal")
            $("#withdrawalQuatoTable").hide();
            $("#withDrawalServicesTable").show();
            $("#vipRewardsTable").hide();
        } else if (tagId == 'vipRewards') {
            $("#withDrawalQuota").addClass("active_order_normal").removeClass("active_order_sel");
            $("#withDrawalServices").addClass("active_order_normal").removeClass("active_order_sel");
            $("#vipRewards").addClass("active_order_sel").removeClass("active_order_normal")
            $("#withdrawalQuatoTable").hide();
            $("#withDrawalServicesTable").hide();
            $("#vipRewardsTable").show();
        }
    })



    $("#mine_top_btn").click(function () {
        $("#copyLink").css({"display": "block"});
    });


    var clipboard = new ClipboardJS('#copy_link_btn');
    clipboard.on('success', function (e) {
        console.log(e);
        //打印动作信息（copy或者cut）
        console.info('Action:', e.action);
        //打印复制的文本
        console.info('Text:', e.text);
        //打印trigger
        console.info('Trigger:', e.trigger);
        toast('Success');
    });


    $(document).click(function (event) {
        var _copy_con = $("#mine_top_btn");
        var flag = false;
        if (!_copy_con.is(event.target) && _copy_con.has(event.target).length === 0) {
            flag = true;
        } else {
            return;
        }

        if (flag) {
            $("#copyLink").css({"display": "none"})
        }
    });
})

/**
 * 判断今天是否已签到
 */
function isExitTodaySignIn() {
    var data = {}
    $.ajax({
        type: "get",
        url: "../signIn/isExitSignIn",
        dataType: "json",
        contentType: "application/json",
        data: data,
        success: function (msg) {
            console.log(msg.data)
            if (msg.success) {
                if (msg.data) {
                    //已签到
                    $("#signInBonus").html("Signed in");
                    $("#signInBonus").removeAttr("onclick");
                } else {
                    //未签到
                    $("#signInBonus").html("Sign In Bonus &gt;");
                    $("#signInBonus").click(function () {
                        //signInBonus
                        startTodySignIn();
                    })
                }
            }
        }
    })
}


function followUs(url) {
    window.location.href = url;
}

//开始签到
function startTodySignIn() {
    var data = {}
    $.ajax({
        type: "get",
        url: "../signIn/userSignIn",
        dataType: "json",
        contentType: "application/json",
        data: data,
        success: function (msg) {
            console.log(msg.data)
            if (msg.success) {
                $("#signInBonus").html("Signed in");
                $("#signInBonus").removeAttr("onclick");
                window.location.reload();// 不刷新  可以一直签到
            } else {
                alert(msg.message);
            }
        }
    })
}